package com.hq.ims.userpc.busservice;

import com.hq.authority.utils.AppUtils;
import com.hq.ims.data.service.BaseBusInfoTrackService;
import com.hq.ims.data.service.BaseBusiInfoService;
import com.hq.ims.data.vo.BusInfoTrackMapstruct;
import com.hq.ims.data.vo.BusiInfoMapstruct;
import com.hq.ims.data.vo.pic.BusiInfoTraceCompanyTreeVo;
import com.hq.mybatis.base.page.RequestPage;
import com.hq.mybatis.base.page.ReturnPage;
import com.hq.utils.vo.ReturnVo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author cx
 * @date 2024/11/26 11:21:02
 * @description 经营信息一张图Service
 */
@Service
public class UserBusiInfoMapService {

    @Resource
    private BaseBusInfoTrackService baseBusInfoTrackService;
    @Resource
    private BaseBusiInfoService baseBusiInfoService;

    /**
     * 我发布的经营信息-按项目查询
     *
     * @param page     分页对象
     * @param searchVo 查询条件对象
     * @return ReturnVo
     */
    public ReturnVo<ReturnPage<BusiInfoMapstruct.BusiInfoVo>> getBusiInfoPage(RequestPage<BusiInfoMapstruct.BusiInfoVo> page,
                                                                              BusiInfoMapstruct.PageSearchVo searchVo) {
        searchVo.setPublisherId(AppUtils.getUserId());
        baseBusiInfoService.getByPage(page, searchVo);
        return ReturnVo.buildSuccess(page.getReturnPage());
    }

    /**
     * 查询经营信息跟踪-公司查询
     *
     * @return ReturnVo
     */
    public ReturnVo<BusiInfoTraceCompanyTreeVo> getBusInfoTraceCountByCompany(String companyName) {
        BusiInfoTraceCompanyTreeVo companyTreeVo = baseBusInfoTrackService.getBusInfoTraceCountByCompany(Boolean.TRUE, companyName);
        return ReturnVo.buildSuccess(companyTreeVo);
    }

    /**
     * 经营信息跟踪查询-按公司查询
     *
     * @param page      分页对象
     * @param companyId 公司id
     * @return ReturnVo
     */
    public ReturnVo<ReturnPage<BusInfoTrackMapstruct.BusInfoTrackVo>> getBusiInfoTrackByPage(RequestPage<BusInfoTrackMapstruct.BusInfoTrackVo> page,
                                                                                             String companyId) {
        BusInfoTrackMapstruct.PageSearchVo param = new BusInfoTrackMapstruct.PageSearchVo();
        param.setCompanyId(companyId);
        baseBusInfoTrackService.getByPage(page, param);
        return ReturnVo.buildSuccess(page.getReturnPage());
    }
}
